package top.handsome.sort;

import top.handsome.ArrayPrinter;

public class BubbleSort {

    public static void main(String[] args) {
        int[] list = {2, 45, 6, 7, 32, 4, 1, 42, 5234};
        sortAndPrint(list);
    }


    public static void sortAndPrint(int[] arrays) {
        int n;
        for (int i = 0; i < arrays.length; i++) {
            for (int j = 0; j < arrays.length - 1 - i; j++) {
                if (arrays[j] > arrays[j + 1]) {
                    n = arrays[j];
                    arrays[j] = arrays[j + 1];
                    arrays[j + 1] = n;
                }
            }
        }
        ArrayPrinter.printf(arrays);
    }

}
